﻿import mx.events.EventDispatcher;
import mx.utils.Delegate;

import com.mixmedia.mx.Event;
import com.mixmedia.mx.IEventDispatcher;
/**
 * @author Colin
 */
class com.mixmedia.mx.MovieClipEvt implements IEventDispatcher{
	static public var EVENTENTERFRAME:String = Event.ENTERFRAME;
	
	public var mc:MovieClip;
	private var delEnterFrame:Function;
	private var delPress:Function;
	private var delRelease:Function;
	private var delOver:Function;
	private var delOut:Function;
	
	public function MovieClipEvt(mc){
		EventDispatcher.initialize(this);
		delEnterFrame 	= Delegate.create(this,onEnterFrameCall);
		delPress		= Delegate.create(this,onPressCall);
		delRelease		= Delegate.create(this,onReleaseCall);
		delOver			= Delegate.create(this,onOverCall);
		delOut			= Delegate.create(this,onOutCall);

		
		this.mc = mc;
		mc.useHandCursor = false;
		enableOnEnterFrameEvent(true);
	}

	public function enableOnEnterFrameEvent(b:Boolean){
		mc.onEnterFrame = (b)?delEnterFrame:null;
	}
	
	public function enableOnPressEvent(b:Boolean){
		mc.onPress = (b)?delPress:null;
	}

	public function enableOnReleaseEvent(b:Boolean){
		mc.onRelease = (b)?delRelease:null;
	}

	public function enableOnOverEvent(b:Boolean){
		mc.onRollOver = (b)?delOver:null;
	}

	public function enableOnOutEvent(b:Boolean){
		mc.onRollOut = (b)?delOut:null;
	}

	private function onPressCall(){
		dispatchEvent(new Event(this,Event.CLICK));
	}
	
	private function onReleaseCall(){
		dispatchEvent(new Event(this,Event.RELEASE));
	}
	
	private function onOverCall(){
		dispatchEvent(new Event(this,Event.ROLLOVER));
	}
	
	private function onOutCall(){
		dispatchEvent(new Event(this,Event.ROLLOUT));
	}
	
	private function onEnterFrameCall(){
		dispatchEvent(new Event(this,Event.ENTERFRAME));
	}
	
	private function dispatchEvent() {};
	public function addEventListener(event : String, handler) : Void {}
	public function removeEventListener(event : String, handler) : Void {}
}